package com.aaa.controller;

import com.aaa.entity.Product;
import com.aaa.service.ProductService;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：Mickey
 * @date ：Created in 2022/11/17 15:13
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("product")
@Slf4j
public class ProductController {
    @Autowired
    private ProductService productService;

    @GetMapping("/getById/{pid}")
    public Product getById(@PathVariable Long pid){
        Product product = productService.findById(pid);
        log.info("查询的商品"+ JSON.toJSONString(product));
        return product;
    }
}
